Skip to content

feat: add support for serialization compatibility with newer Laravel#389

Merged
albertcht merged 6 commits into
0.3from
feature/laravel-queue-compatible
May 17, 2026
Merged

feat: add support for serialization compatibility with newer Laravel#389
albertcht merged 6 commits into
0.3from
feature/laravel-queue-compatible

Conversation

@albertcht
Copy link
Copy Markdown
Member

Background

Newer versions of Laravel added the #[AllowDynamicProperties] attribute to CallQueuedListener. Without it, PHP 8.2+ emits deprecation notices when dynamic properties are assigned during unserialization, and stricter future PHP versions will throw errors outright.

More critically, this creates a cross-version serialization breakage: if a job is serialized (pushed to queue) with a Laravel version where CallQueuedListener carries additional properties — then deserialized (popped from queue) by a worker running a different version without the attribute — PHP rejects the unknown properties. The result is a fatal unserialization error that silently kills queued jobs.

Changes

src/event/src/CallQueuedListener.php · src/event/illuminate/CallQueuedListener.php

Added the #[AllowDynamicProperties] attribute to both Hypervel\Event\CallQueuedListener and the Illuminate\Events\CallQueuedListener shim. This mirrors the upstream Laravel change and ensures dynamic properties set during unserialization are accepted without error, regardless of which version serialized the payload.

src/queue/src/CallQueuedClosure.php

Ported the name() feature from newer Laravel, which allows queued closures to carry a human-readable display name:

  • Added public ?string $name = null; property
  • Added name(string $name): static fluent method
  • Updated displayName() to prefix the output when a name is set: MyJob - Closure (DispatchesJobs.php:42)

Why both CallQueuedListener files?

Hypervel ships two variants of CallQueuedListener:

  • Hypervel\Event\CallQueuedListener — the native Hypervel implementation
  • Illuminate\Events\CallQueuedListener — a shim under the Illuminate namespace for compatibility with packages that dispatch listeners via the standard Laravel namespace

Both must carry the attribute so payloads are interchangeable regardless of which class path was used to serialize them.

Impact

  • Fixes fatal unserialization errors when queue workers and producers run against mismatched CallQueuedListener class shapes
  • No breaking changes; $name defaults to null and displayName() output is unchanged when no name is set
  • PHP 8.1 minimum is preserved (#[AllowDynamicProperties] is available since PHP 8.1)

@albertcht albertcht changed the title Feat: Add support for serialization compatibility with newer Laravel feat: Add support for serialization compatibility with newer Laravel May 17, 2026
@albertcht albertcht changed the title feat: Add support for serialization compatibility with newer Laravel feat: add support for serialization compatibility with newer Laravel May 17, 2026
@albertcht albertcht added the enhancement Improved feature or adjustments. label May 17, 2026
@albertcht albertcht merged commit 05b2b4a into 0.3 May 17, 2026
16 checks passed
@albertcht albertcht deleted the feature/laravel-queue-compatible branch May 17, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improved feature or adjustments.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant